﻿#include "QLineEditBase.h"

QCOMMWIDGETS_BEGIN_NAMESPACE

//显示文字构造函数 输入框
QGroupLineEdit::QGroupLineEdit(const QString text, const QFont ft,QFlags<Qt::AlignmentFlag> alig, const QColor text_color,QLineEdit::EchoMode m_pEditType, QString StyleSheet, QWidget *parent)
:QLineEdit(parent), m_pAlignmentFlag(alig),m_pEditType(m_pEditType)
{
	QPalette pe;
	pe.setColor(QPalette::WindowText, text_color);
	this->setPalette(pe);
	this->setFont(ft);
	this->setText(text);
	this->setAlignment(alig);
	//if(m_pEditType == QLineEdit::Password)
	{
		
		setEchoMode(m_pEditType);
	}
	// 设置控件不接受焦点
	this->setFocusPolicy(Qt::NoFocus);
	// 设置样式表
	this->setStyleSheet(StyleSheet);
	setAttribute(Qt::WA_AcceptTouchEvents,true); //接受所有触摸事件
}

//析构函数
QGroupLineEdit::~QGroupLineEdit()
{

}

//设置显示文字
void QGroupLineEdit::SetQStringText(QString text)
{
	this->setText(text);
	
}

//获取显示文字
QString QGroupLineEdit::GetQStringText()
{
	return this->text();
	
}

//清除当前显示的内容
void QGroupLineEdit::ClearText()
{
	this->clear();
}

//窗口尺寸变化自动调用函数
void QGroupLineEdit::resizeEvent(QResizeEvent *event)
{
	QLineEdit::resizeEvent(event);
}

bool QGroupLineEdit::event(QEvent *event)
{

    switch(event->type())
    {
    case QEvent::TouchBegin:
        {
            event->accept();
            return true;

        }

    case QEvent::TouchUpdate:
        {
            event->accept();
            return true;
        }
    case QEvent::TouchEnd:			//触摸松开后
        {
            event->accept();
            // 发送被点击事件
            emit clickedMsg();
            return true;
        }
    default:
    	break;
    }
    return QLineEdit::event(event);
}
QCOMMWIDGETS_END_NAMESPACE
